/**
 *  Copyright 2012 Antoine RADET
 *
 *   This file is part of Film Collection.
 *
 *   Film Collection is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   Film Collection is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Film Collection.  If not, see <http://www.gnu.org/licenses/>.
*/

/**
 * \file movie.h
 * \brief Structures, functions and constants declaration for movies
 * \author Antoine RADET
 */

#ifndef MOVIE_H
#define MOVIE_H

/**
 * \def MOVIE_PATH
 * \brief Path for movie save
 */
#define MOVIE_PATH  "../data/movies/"

/**
 * \def MOVIE_EXT
 * \brief Extension for movie files
 */
#define MOVIE_EXT  ".movie"

/**
 * \def PATH_LENGTH
 * \brief Number of characters in saving datapath
 */
#define PATH_LENGTH 100

/**
 * \def SIZE_MAX_TITLE
 * \brief Maximum size for movie title
 */
#define SIZE_MAX_TITLE  100

/**
 * \def SIZE_MAX_NAME
 * \brief Maximum size for a name (director, actors, ...)
 */
#define SIZE_MAX_NAME  50

/**
 * \def NBR_MAX_MAIN_ACTORS
 * \brief Maximum number of main actors
 */
#define NBR_MAX_MAIN_ACTORS  5

/**
 * \def SIZE_MAX_LANG
 * \brief Maximum size for a language
 */
#define SIZE_MAX_LANG  20

/**
 * \def NBR_MAX_LANG
 * \brief Maximum number of differents languages or subtitles languages
 */
#define NBR_MAX_LANG  6

/**
 * \enum Genre
 * \brief Indicate the genre of a film
 */
typedef enum{
    ACTION,
    ADVENTURE,
    ANIMATED,
    BIOPIC,
    BOLLYWOOD,
    CARTOON,
    CLASSICAL,
    COMEDY,
    COMEDY_DRAMA,
    CONCERT,
    DETECTIVE,
    DOCUMENTARY,
    DRAMA,
    EROTIC,
    FAMILY,
    FANTASY,
    HISTORICAL,
    HORROR,
    JUDICIAL,
    MARTIAL_ART,
    MOVIE_NIGHT,
    MUSICAL,
    MUSICAL_COMEDY,
    OPERA,
    PEPLUM,
    ROMANCE,
    SCIENCE_FICTION,
    SHOW,
    SPORT_EVENT,
    SPYING,
    THRILLER,
    UNKNOWN,
    VARIOUS,
    WAR,
    WESTERN
}Genre;


/**
 * \enum Media
 * \brief Indicate a type of digital media
 */
typedef enum{
    DVD,        /*!< DVD */
    BLU_RAY     /*!< Blu-Ray */
}Media;


/**
 * \enum MovieInformation
 * \brief Different type of information about a film
 */
typedef enum{
    TITLE,
    YEAR,
    DIRECTOR,
    MAIN_ACTORS,
    GENRE,
    DURATION,
    LANGUAGES,
    SUBTITLES,
    MEDIA,
    LINK,
    SYNOPSIS,
    IMG_PATH,
    END         /*!< Indicate the end of a MovieInformation list */
}MovieInformation;

/**
 * \struct Movie
 * \brief Contains all information about a film
 */
typedef struct {
    char title[SIZE_MAX_TITLE]; /*!< Movie's title */
    int year;                   /*!< Release date */
    char director[SIZE_MAX_NAME];                         /*!< Film director */
    char mainActors[NBR_MAX_MAIN_ACTORS * SIZE_MAX_NAME]; /*!< Main actors */
    Genre  genre;               /*!< Film genre */
    int duration;               /*!< Film duration */
    char languages [NBR_MAX_LANG * SIZE_MAX_LANG];       /*!< Available languages */
    char subtitles [NBR_MAX_LANG * SIZE_MAX_LANG];       /*!< Available subtitles languages */
    Media  media;               /*!< Type of media */
    char allocineLink[2*SIZE_MAX_TITLE];                 /*!< Link to full description on alloCine.com */
    char * synopsis;            /*!< Short description */
    char imagePath[PATH_LENGTH];                        /*!< Path to the DVD jacket */
}Movie;

/* Create a new movie and initialize it */
Movie * movie_new(void);

/* Free an existing movie */
void movie_delete (Movie *ptrMov);

/* Initialize every field to 0, "" or NULL */
void movie_init (Movie *ptrMov);

/* Set some information field of a movie */
short movie_setInformation (Movie *ptrFilm, MovieInformation info, ...);

/* Save the current movie information into a binary file */
int movie_saveMovie (Movie *ptrMov, char *savePath);

/* Open a movie file */
Movie * movie_openMovie (char * name);

/* Convert a string into the default movie filename */
char * convert_filename (char * movieName);

#endif

